package com.yang.entity;

import java.sql.Timestamp;
import java.util.List;

import com.mysql.jdbc.StringUtils;

public class User {
	private int id;
	private String name;
	private gender sex;
	private Timestamp birth;
	private List<Role> role;
	private Double cash;

	public User() {
	}

	public User(String name, gender sex, double cash) {
		this.name = name;
		this.sex = sex;
		this.setCash(cash);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public gender getSex() {
		return sex;
	}

	public void setSex(gender sex) {
		this.sex = sex;
	}

	public Timestamp getBirthDate() {
		return birth;
	}

	public void setBirthDate(Timestamp birthDate) {
		this.birth = birthDate;
	}
	public List<Role> getRole() {
		return role;
	}

	public void setRole(List<Role> role) {
		this.role = role;
	}

	@Override
	public String toString() {
		String temp = "";
		for(Role role : role){
			temp += role.getName()+",";
		}
		if(!StringUtils.isEmptyOrWhitespaceOnly(temp)){
			temp = temp.substring(0,temp.length()-1);
		}
		return this.name+"--"+this.birth+"----"+temp;
	}

	public Double getCash() {
		return cash;
	}

	public void setCash(Double cash) {
		this.cash = cash;
	}
}
